package com.yanqu.road.server.cmd.mogulbirthday;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.bossbirthday.MogulBirthdayProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.mogulbirthday.MogulBirthdayModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_MOGUL_BIRTHDAY_POSTER_GET_REWARD_FROM_CROSS, desc = "生辰祝福收礼")
public class MogulPosterGetRewardFromCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        MogulBirthdayProto.MogulBirthdayPosterGetRewardRespMsg respMsg = MogulBirthdayProto.MogulBirthdayPosterGetRewardRespMsg.parseFrom(packet.getBytes());

        ret = player.getModule(MogulBirthdayModule.class).posterRewardFromCross(respMsg.getReward(), respMsg.getMogulId());
    }

    @Override
    public void sendData(GamePlayer player) {

        if(ret != 0){
            MogulBirthdayProto.MogulBirthdayPosterGetRewardRespMsg.Builder respMsg = MogulBirthdayProto.MogulBirthdayPosterGetRewardRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_MOGUL_BIRTHDAY_POSTER_GET_REWARD, respMsg);
        }
    }
}
